//将文章集合的构造 函数解构导入到当前文件中
const { Article } = require('../../modle/article');
//将评论集合构造函数进行导入
const { Comment } = require('../../modle/comment');

module.exports = async(req, res) => {
    //接收客户端传递过来的id值
    const id = req.query.id;
    //根据id查询文章详情信息
    let article = await Article.findOne({_id: id}).populate('author');
    article = JSON.parse(JSON.stringify(article));

    //根据id查询文章详情信息
    let comments = await Comment.find({aid: id}).populate('uid');
    comments = JSON.parse(JSON.stringify(comments));
    //res.send('欢迎来到博客文章的详情展示页面')
    res.render('home/article.art', {
        article: article,
        comments: comments
    });
}